//============================================================================
//	警告: 这个文件是使用2009-8-28 17:56:54建立的IBatisNetGen.DaoImpl.cst生成的.
//				重新生成时,原先手动做的修改将会丢失.
//============================================================================
using System;
using System.Collections.Generic;
using System.Text;
using IBatisNet.DataMapper;
using Bino.ExamOnline.Components.Entitys;
using Bino.ExamOnline.Components.Interface;
using Bino.Common.TextLib;

namespace Bino.ExamOnline.DataProvider 
{	
    /// <summary>实现<see cref="ITopicDao"/>接口.</summary>
    public class TopicDataProvider : DataProviderBase, ITopicDao 
	{
		/// <summary>实现 <see cref="ITopicDao.GetTopicsCount"/></summary>
		public int GetTopicsCount() {
			string statementId = "Topic.GetTopicsCount";
			int result = ExecuteQueryForObject<int>(statementId, null);
			return result;
		}

		/// <summary>实现 <see cref="ITopicDao.GetTopic"/></summary>
		public Topic GetTopic(Int32 iD) 
		{
			string statementId = "Topic.GetTopic";
			Topic result = ExecuteQueryForObject<Topic>(statementId, iD);
			return result;
		}

		/// <summary>实现 <see cref="ITopicDao.GetTopicWithOutLob"/></summary>
		public Topic GetTopicWithOutLob(Int32 iD) 
		{
			string statementId = "Topic.GetTopicWithOutLob";
			Topic result = ExecuteQueryForObject<Topic>(statementId, iD);
			return result;
		}

		/// <summary>实现 <see cref="ITopicDao.GetAllTopics"/></summary>
		public IList<Topic> GetAllTopics() 
		{
			string statementId = "Topic.GetAllTopics";
			IList<Topic> results = ExecuteQueryForList<Topic>(statementId, null);
			return results;
		}

		/// <summary>实现 <see cref="ITopicDao.GetAllTopicsWithOutLob"/></summary>
		public IList<Topic> GetAllTopicsWithOutLob()
		{
			string statementId = "Topic.GetAllTopicsWithOutLob";
			IList<Topic> results = ExecuteQueryForList<Topic>(statementId, null);
			return results;
		}
	
		/// <summary>实现 <see cref="ITopicDao.CreateTopic"/></summary>
		public void CreateTopic(Topic obj)
		{
			if (obj == null) 
				return;
			string statementId = "Topic.CreateTopic";
			ExecuteInsert(statementId, obj);
		}

		/// <summary>实现 <see cref="ITopicDao.UpdateTopic"/></summary>
		public void UpdateTopic(Topic obj) 
		{
			if (obj == null) 
				return;
			string statementId = "Topic.UpdateTopic";
			ExecuteUpdate(statementId, obj);
		}

		/// <summary>实现 <see cref="ITopicDao.DeleteTopic"/></summary>
		public void DeleteTopic(Topic obj) 
		{
			if (obj == null)
				return;
			string statementId = "Topic.DeleteTopic";
			ExecuteDelete(statementId, obj);
		}

		/// <summary>实现 <see cref="ITopicDao.DeleteTopicByID"/></summary>
		public int DeleteTopicByID(Int32 iD) 
		{
			string statementId = "Topic.DeleteTopicByID";
            int result = Bino.Common.TextLib.StringHelper.SafeInt(ExecuteDelete(statementId, iD).ToString(), -1);
			return result;
		}		

		/// <summary>实现 <see cref="ITopicDao.ReloadTopic"/></summary>
		public void ReloadTopic(Topic obj) 
		{
			if (obj == null) 
				return;
			string statementId = "Topic.GetTopic";
			ExecuteQueryForObject<Topic>(statementId, obj, obj);
		}

        /// <summary>
        /// 统计考试题库指定题型数量
        /// </summary>
        /// <param name="TopicTypeID"></param>
        /// <returns></returns>
        public int GetTopicsCount(int TopicTypeID)
        {
            string statementId = "Topic.GetTopicsCountByTopicTypeID";
            int result = ExecuteQueryForObject<int>(statementId, TopicTypeID);
            return result;
        }

        /// <summary>随机获取试题</summary>
        public IList<Topic> GetTopicsByRand(int TopicTypeID, int count)
        {
            string statementId = "Topic.GetTopicsByRand";
            IList<Topic> results = ExecuteQueryForList<Topic>(statementId, TopicTypeID,0,count);
            return results;
        }

	}
}
